# 金融街 涨跌停1分钟数据统计 数据
from apscheduler.schedulers.blocking import BlockingScheduler
from datetime import datetime
from data.jrj import statisticsMinutes


def writeData():
    """保存数据到文件"""
    data = statisticsMinutes()
    with open('./data/dataJRJ/' + datetime.now().strftime("%Y-%m-%d") + '.js', 'w', encoding='utf-8') as file:
        file.write(data)
        file.close()
        print('./data/dataJRJ/' + datetime.now().strftime("%Y-%m-%d") + '.js', 'finish')


def job():
    print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
    writeData()


writeData()
# BlockingScheduler
scheduler = BlockingScheduler()
scheduler.add_job(job, 'cron', day_of_week='1-5', hour=15, minute=1)  # 周一到周五 15:01 运行任务
scheduler.start()
